<?php

namespace app\xs_test\command;

use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\Output;

class TestCommand extends Command
{
    protected static $defaultName = 'TestCommand';

    protected function configure()
    {
        $this->setName(self::$defaultName)
            ->addArgument('action', Argument::OPTIONAL, "action  start [d]|stop|restart|status")
            ->addArgument('type', Argument::OPTIONAL, "d -d")
            ->setDescription('多应用下命令行测试');
    }

    protected function execute(Input $input, Output $output)
    {
        $action = trim($input->getArgument('action'));
        $type = trim($input->getArgument('type')) ? '-d' : '';

        // 执行案例 php think xsTestTestCommand start d
        // 执行案例 php think xsTestTestCommand stop d

        $output->writeln(self::$defaultName . " {$action} {$type} run success " . date('Y-m-d H:i:s'));
    }

}